package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.UserPredictEcologyHatchRewardsRecords;
import com.sc.nft.entity.UserPrizeDrawRecords;
import com.sc.nft.enums.PrizeDrawActivityRewardsEnum;
import com.sc.nft.mapper.UserPredictEcologyHatchRewardsRecordsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.dao
 * @Project：sc_metago
 * @name：UserPredictEcologyHatchRewardsRecordsDao
 * @Date：2024/8/9 15:52
 * @Filename：UserPredictEcologyHatchRewardsRecordsDao
 */
@Slf4j
@Repository
public class UserPredictEcologyHatchRewardsRecordsDao extends ServiceImpl<UserPredictEcologyHatchRewardsRecordsMapper, UserPredictEcologyHatchRewardsRecords> {


    /**
     * 批量插入预计奖励列表
     *
     * @param userPredictEcologyHatchRewardsRecordsList
     */
    public void saveList(List<UserPredictEcologyHatchRewardsRecords> userPredictEcologyHatchRewardsRecordsList) {
        baseMapper.saveList(userPredictEcologyHatchRewardsRecordsList);
    }

    /**
     * @param startTime
     * @param endTime
     * @return
     */
    public List<UserPredictEcologyHatchRewardsRecords> getNeedIssueList(Date startTime, Date endTime) {
        return baseMapper.getNeedIssueList(startTime, endTime);
    }

    public Boolean updateStatusById(Long id, Boolean status) {
        LambdaUpdateWrapper<UserPredictEcologyHatchRewardsRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserPredictEcologyHatchRewardsRecords::getId,id);
        wrapper.set(UserPredictEcologyHatchRewardsRecords::getIsSettle,status);
        return update(wrapper);
    }

    public Boolean hasList(Long userId, Long userEcologyHatchRecordsId) {
        LambdaQueryWrapper<UserPredictEcologyHatchRewardsRecords> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(UserPredictEcologyHatchRewardsRecords::getUserId, userId);
        lambdaQueryWrapper.eq(UserPredictEcologyHatchRewardsRecords::getUserEcologyHatchRecordsId, userEcologyHatchRecordsId);
        return count(lambdaQueryWrapper) > 0;
    }

}
